package cloud.psn.kiko.mail.rest;

import cloud.kiko.psn.pojo.common.R;
import cloud.kiko.psn.pojo.common.baz.mail.Mail;
import cloud.psn.kiko.mail.service.EmailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("mail")
public class EmailRest {
    @Autowired
    private EmailService emailService;

    @PostMapping("text")
    public R<?> textEmail(@RequestBody Mail mail) {
        emailService.sendMail(mail,false);
        return R.ok("邮件发送成功");
    }

    @PostMapping("html")
    public R<?> htmlEmail(@RequestBody Mail mail) {
        emailService.sendMail(mail,true);
        return R.ok("邮件发送成功");
    }
}
